#include <Buffer.h>

#include <fstream>
#include <iostream>
#include <filesystem>
#include <memory>

class CreateOnlyStack
{
public:
    CreateOnlyStack() = default;
    ~CreateOnlyStack() = default;

    // 1、禁用new操作符
    void *operator new(size_t) = delete;
    void *operator new[](size_t) = delete;

    void* operator new(size_t,void*) = delete; // 禁用placement new

    // 2、隐藏new操作符
// private:
//     void *operator new(size_t);
//     void *operator new[](size_t);

};



int main()
{
    Buffer buffer(16);
    buffer.append("hello");
    std::string str1 = buffer.retrieve(5);
    std::cout << str1 << std::endl;
    buffer.append("hello worldhhhhhhhhhhhhhhhhhhhhhhhhhhhhh!");
    std::string str2 = buffer.retrieveAll();
    std::cout << str2 << std::endl;
    int a = 20;
    buffer.append((char *)&a, sizeof(a));
    a = buffer.retriveAs<int>();
    std::cout << a << std::endl;
    std::cout << buffer.availableSize() << std::endl;
    std::cout << buffer.readableSize() << std::endl;

    CreateOnlyStack obj;
    // new CreateOnlyStack(); // 不可访问
}